var rows2=10;


var myselfPage2;
var myselfPath2;
var myselfSucc2;

var pageEnd2;
var pageIndex2;

/***给页面分页赋值****/
function showpage_2(total,pages){
	var nowpage=Number(pages)/rows2;
	var allpage=Math.ceil(Number(total)/rows2);
	pageEnd2=allpage-1;
	pageIndex2=nowpage;
	$("#allcount_2").html(total);
	$("#rowscount_2").html(rows2);
	$("#allpage_2").html(allpage);
	$("#nowpage_2").html(nowpage+1);
	var option="";
	for(var i=0;i<allpage;i++){
		var val=i+1;
		option+="<option value='"+i+"'>"+val+"</option>"
	}
	$("#pagination_others1 select").html(option);
	$("#pagination_others1 select").val(nowpage);
}

	/**
 * 获取数据
 */
function getPageData_2(param,path,succ){
	myselfPath2=path;
	myselfPage2=param;
	myselfSucc2=succ;
   	param.ajax(path,function(data){
		showpage_2(data.total,data.page);
		succ(data);
		
		//记住当前所选的页面，目的是从其他页面再返回清单页时，保持之前所选的页面
		//window.localStorage.setItem("page",data.page);
	});
}

/**
 * 首页
 * 
 */
function firstPage_2(){
	turnPage_2("0");
}

/**
 * 最后一页
 */
function lastPage_2(){
	turnPage_2(getpageEnd_2());
}

/**
 * 上一页
 */
function prePage_2(){
	var index=getPathIndex_2()-1;
	if(index<0){
		alert("已经是首页了");
	}else{
		turnPage_2(index);
	}
}

/**
 * 下一页
 */
function nextPage_2(){

	var index=getPathIndex_2()+1;
	if(index>getpageEnd_2()){
		alert("已经是最后一页了");
	}else{
		turnPage_2(index);
	}
}

/**
 * 跳转
 */
function jumpPage_2(obj){
	var val=$(obj).val();
	turnPage_2(val);
}


/**
 * 修改page值，显示当前页数据
 * @param index
 * @return
 */
function turnPage_2(index){
	myselfPage2.json["page"]=index*rows2;
	getPageData_2(myselfPage2,myselfPath2,myselfSucc2);
}




function getPathIndex_2(){
	return pageIndex2;
}

/**
 * 最后一页
 * @return
 */
function getpageEnd_2(){
	return pageEnd2;
}
